﻿//逻辑代码
import {Puerts, ScreenMgr, UnityEngine} from 'csharp'
import {$typeof} from 'puerts'
import {Component} from 'framework/component/component';
import TweenedScreen = ScreenMgr.TweenedScreen;
import Button = UnityEngine.UI.Button;
import ScreenManager = ScreenMgr.ScreenManager;
import {ServiceLocator} from "framework/decorator/serviceLocator";

class MainMenu  extends Component
{
    arg0 : Button = null;
    arg1:Button=null;
    arg2:Button=null;
    constructor(behaviour:Puerts.JsBehaviour) {
        super(behaviour);
        this.applyArgs()
    }
    //Awake(){
    //  console.log('js Awake ...')
    // }
    Start (){
        this.arg0.onClick.AddListener( ()=>this.button1click())
        this.arg1.onClick.AddListener( ()=>this.button2click())
        this.arg2.onClick.AddListener( ()=>this.button3click())
        console.log("MainMenu Start ...")
    }
    button1click(){
        ServiceLocator.Get(ScreenManager).Show("Popup","你好,你的手机已经欠费")
    }
    button2click(){
        ServiceLocator.Get(ScreenManager).Show("Popup","你好,恭喜你获得三个金币")
    }
    button3click(){
        ServiceLocator.Get(ScreenManager).Show("Popup","你好\n你妈叫你回家收衣服")
    }
    //OnEnable(){
    //      console.log('js OnEnable ...')
    // }
    //OnDisable(){
    //      console.log('js OnDisable ...')
    // }
    // LateUpdate(){//注册到componentmgr的事件        
    // }
    //FixedUpdate(){//注册到componentmgr的事件
    //}
    // Update() //注册到componentmgr的事件
    // {
    //     //js不支持操作符重载所以Vector3的乘这么用
    //     let r = UnityEngine.Vector3.op_Multiply(UnityEngine.Vector3.up, UnityEngine.Time.deltaTime * 10);
    //     this.behavior.transform.Rotate(r);
    // }
    public OnDestroy() {
        console.log('Mainmenu OnDestroy...');
    }
}

export function init (jsBehavior:Puerts.JsBehaviour) {
    new MainMenu(jsBehavior);
}
